<?php
/**
 * View类
 * 被Controller调用，完成不同功能的网页显示
 */
class View
{
    var $output; //用于保存输出HTML代码的字符串
	var $tpl;
	function __construct()
    {
		$this->tpl = new Smarty;
		$this->tpl->compile_check = true;
		$this->tpl->debugging = false;
	}
    function p($t)
    {
        //输出最终格式化的HTML数据
        $this->tpl->display($t);
    }
}

//显示所分类
class categoryListView extends View
{
    function __construct($notes)
    {
		parent::__construct();
        $this->tpl->assign("lists_pay", $notes['pay']);
        $this->tpl->assign("lists_income", $notes['income']);
    }
}

//显示消费条目列表
class itemListView extends View
{
    function __construct($notes, $re=0)
    {
		parent::__construct();
        if ($re){ //显示操作结果信息
            $this->tpl->assign("msg_content", $re);
        }
        $this->tpl->assign("list_items", $notes);
    }
}

//显示添加条目页面
class addView extends View
{
    function __construct($notes)
    {
		parent::__construct();
        $this->tpl->assign("option_values_pay", $notes[0][0]);
        $this->tpl->assign("option_values_income", $notes[0][1]);
		$this->tpl->assign("option_output_pay", $notes[1][0]);
		$this->tpl->assign("option_output_income", $notes[1][1]);
		$this->tpl->assign("option_selected_pay", $notes[2][0]);
		$this->tpl->assign("option_selected_income", $notes[2][1]);
		$this->tpl->assign("item_values", $notes[3]);
		$this->tpl->assign("type", $notes[4]);
    }
}

//显示添加消费条目结果
class postView extends View
{
    function __construct($re)
    {
        if ($re){ // 添加成功
            header("location:money_list.php?ac=edit");
            die();
        }else{
            die("添加失败！");
		}
    }
}
?>